﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mec="clr-namespace:Microsoft.Expression.Controls;assembly=Microsoft.Expression.Controls" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:mycontrols="clr-namespace:AzureTracer.Views.Controls"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    x:Class="AzureTracer.Views.SettingsPage"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding Settings,Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Name="ScrollViewerTemplate">
            <TextBlock Text="{Binding Value}"/>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <!--Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:SlideTransition Mode="SlideUpFadeIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:SlideTransition Mode="SlideDownFadeOut"/>
            </toolkit:NavigationOutTransition.Backward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" 
                       Text="{Binding Labels.ConfigurationUpper, Source={StaticResource LabelsManager}}"
                       Style="{StaticResource PhoneTextNormalStyle}"/>
            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                <Border BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="50" Padding="0" Margin="10,0,0,0">
                    <Border.Background>
                        <ImageBrush Stretch="Uniform" ImageSource="/Resources/Images/Cloud.png"/>
                    </Border.Background>
                </Border>
                <TextBlock  
                    FontWeight="Bold" FontSize="28" 
                    Text="{Binding Labels.AppTitle, Source={StaticResource LabelsManager}}" 
                    VerticalAlignment="Center" Margin="10,0,0,0" />
            </StackPanel>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <ScrollViewer x:Name="ContentPanel" Margin="12,0,12,0" Grid.Row="1" >
            <StackPanel >
                <TextBlock  
                    Text="{Binding Labels.DownloadNewContent, Source={StaticResource LabelsManager}}"
                    Margin="3,0,0,0" />
                <toolkit:ListPicker 
                    ItemsSource="{Binding NewContent}"
                    ItemTemplate="{StaticResource ScrollViewerTemplate}" 
                    SelectedItem="{Binding NewContentSelection, Mode=TwoWay}"/>
                <TextBlock 
                    Text="{Binding Labels.DownloadTraceFrom, Source={StaticResource LabelsManager}}"
                    Margin="0,18,0,0" />
                <toolkit:ListPicker                    
                    ItemsSource="{Binding TraceFrom}"
                    ItemTemplate="{StaticResource ScrollViewerTemplate}"
                    SelectedItem="{Binding TraceFromSelection, Mode=TwoWay}"/>
                <Button Margin="0,36,0,0"
                    Content="{Binding Labels.SignOut, Source={StaticResource LabelsManager}}" 
                    Command="{Binding SignOutCommand}"/>
                <TextBlock 
                    Text="{Binding Labels.SignOutHint, Source={StaticResource LabelsManager}}"
                    TextAlignment="Center" FontSize="18" TextWrapping="Wrap" />
                <Grid 
                	Margin="0,72,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <HyperlinkButton
                        Grid.Column="0"
                        HorizontalAlignment="Left"
                		Content="{Binding Labels.ByMe, Source={StaticResource LabelsManager}}" 
                		Click="AboutMeButton_Click" />
                    <StackPanel                         
                        Grid.Column="1"
                        Margin="0,0,14,0"                        
                        Orientation="Horizontal">
                        <TextBlock
                			Text="Version" d:LayoutOverrides="Height"/>
                        <TextBlock
                            Margin="8,0,0,0"
                			Text="{Binding Labels.AppVersion, Source={StaticResource LabelsManager}}" d:LayoutOverrides="Height"/>
                    </StackPanel>
                </Grid>
                <HyperlinkButton
                    Margin="0,16,0,0"
                    Content="{Binding Labels.SendFeedback, Source={StaticResource LabelsManager}}"                   
                    Command="{Binding SendFeedbackEmailCommand}" HorizontalAlignment="Left"/>
            </StackPanel>
        </ScrollViewer>

        <mycontrols:BindableApplicationBar x:Name="AppBar" >
            <mycontrols:BindableApplicationBarIconButton 
                Command="{Binding SaveCommand}" 
                IconUri="/Resources/Images/appbar.check.rest.png" 
                Text="{Binding Labels.Save, Source={StaticResource LabelsManager}}"/>
            <mycontrols:BindableApplicationBarIconButton 
                Command="{Binding CancelCommand}"                                                
                IconUri="/Resources/Images/appbar.cancel.rest.png" 
                Text="{Binding Labels.Cancel, Source={StaticResource LabelsManager}}"/>
        </mycontrols:BindableApplicationBar>
    </Grid>
</phone:PhoneApplicationPage>
